//
//  systemCell.m
//  tcpoctest
//
//  Created by gump on 10/26/12.
//  Copyright (c) 2012 gump. All rights reserved.
//

#import "systemCell.h"
#import "PublicFun.h"
#import <QuartzCore/QuartzCore.h>

@implementation systemCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGRect headFrame = CGRectMake(10, (60 - 44)/2, 44, 44);
        self.mimageview = [[UIImageView alloc]initWithFrame:headFrame];
        self.mimageview.userInteractionEnabled = YES;
        self.mimageview.layer.cornerRadius = 5;
        self.mimageview.layer.masksToBounds = YES;
        [self.contentView addSubview:self.mimageview];
        
        self.mtitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 2, 170, 30)];
        self.mtitleLabel.backgroundColor = [UIColor clearColor];
        self.mtitleLabel.textColor = [UIColor blackColor];
        self.mtitleLabel.font = BLOD_CELL_TITLE_FONT;
        self.mtitleLabel.highlightedTextColor = [UIColor whiteColor];
		self.mtitleLabel.textAlignment = UITextAlignmentLeft;
        [self.contentView addSubview:self.mtitleLabel];
        
        self.mpromptLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 32, 220, 20)];
        self.mpromptLabel.backgroundColor = [UIColor clearColor];
        self.mpromptLabel.textColor = [UIColor grayColor];
        self.mpromptLabel.font = SMALL_CELL_TITLE_FONT;
        [self.contentView addSubview:self.mpromptLabel];
        
        self.mtimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(240, 6, 75, 20)];
        self.mtimeLabel.backgroundColor=[UIColor clearColor];
        self.mtimeLabel.textColor=[UIColor grayColor];
        self.mtimeLabel.textAlignment = UITextAlignmentRight;
        self.mtimeLabel.font = [UIFont systemFontOfSize:14.0f];
        [self.contentView addSubview:self.mtimeLabel];
        
        //未读消息的提示
        self.PromptView = [[UIImageView alloc] initWithFrame:CGRectMake(38, 6, 17, 17) ];
        self.PromptView.image = [UIImage imageNamed:@"tab_unread_bg.png"];
        self.PromptView.hidden = YES;
        [self.contentView addSubview:self.PromptView];
        
        //未读消息的提示数字
        self.PromptLabel = [[UILabel alloc] initWithFrame:CGRectMake(39, 8, 14, 14)];
        self.PromptLabel.backgroundColor = [UIColor clearColor];
        self.PromptLabel.textColor = [UIColor whiteColor];
        self.PromptLabel.textAlignment = UITextAlignmentCenter;
        self.PromptLabel.font = [UIFont systemFontOfSize:12.0f];
        self.PromptLabel.text = @"";
        self.PromptLabel.hidden = YES;
        [self.contentView addSubview:self.PromptLabel];
        
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)ShowBadge:(int)ibadge
{
    self.PromptView.hidden = NO;
    self.PromptLabel.hidden = NO;
    
    self.PromptLabel.text = [NSString stringWithFormat:@"%d",ibadge];
}

-(void)HideBadge
{
    self.PromptView.hidden = YES;
    self.PromptLabel.hidden = YES;
}

@end
